<template>
  <div>
       <el-table
    :data="users"
    style="width: 100%">
    <el-table-column
      label="头像"
      width="180">
        <template slot-scope="scope">
            <img style="width:50px;height:50px" :src="'/api/upload/'+scope.row.userHeader">
      </template>
    </el-table-column>
    <el-table-column
      label="用户名"
      width="180"
      prop="userName"
      >
     
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)">删除</el-button>
      </template>
    </el-table-column>
  </el-table>
   <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pagination.current"
      :page-sizes="[5,10,15,20]"
      :page-size="pagination.size"
      layout="total, sizes, prev, pager, next, jumper"
      :total="pagination.total">
    </el-pagination>
  </div>
</template>

<script>
import {mapState,mapActions} from 'vuex'
export default {
    created(){
        this.setUsers();
    },
    computed:{
        ...mapState("user",["users","pagination"]),
    },
    methods:{
      handleCurrentChange(page,size){
        this.setUsers({page,size});
      },
      handleSizeChange(size){
        this.setUsers({page:this.pagination.current,size})
      },
        ...mapActions("user",["setUsers"])
    }

}
</script>

<style>

</style>